﻿
using Common;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Events;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using WPTrek.Gui.Events;
using WPTrek.Gui.Services;
namespace WPTrek.Gui.ViewModels
{
    public class MenuViewModel : ViewModelBase, IMenuViewModel
    {
        public MenuViewModel(IUnityContainer container, IEventAggregator eventAggregator, IRegionManager regionManager, IDataService dataService)
            : base(container, eventAggregator, regionManager)
        {
            this.dataService = dataService;

            ShowGameViewCommand = new DelegateCommand<object>(OnShowGameViewCommand);
            ShowWorldBuilderCommand = new DelegateCommand<object>(OnShowWorldBuilderCommand);
        }

        #region IMenuViewModel Members

        public DelegateCommand<object> ShowGameViewCommand { get; private set; }

        public DelegateCommand<object> ShowWorldBuilderCommand { get; private set; }

        #endregion

        #region Private methods

        private void OnShowGameViewCommand(object parameter)
        {
            eventAggregator.GetEvent<SwitchViewEvent>().Publish(ViewNames.GameView);
        }

        private void OnShowWorldBuilderCommand(object parameter)
        {
            eventAggregator.GetEvent<SwitchViewEvent>().Publish(ViewNames.WorldBuilderView);
        }

        #endregion

        private readonly IDataService dataService;
    }
}
